<template>
  <!-- 管理员界面 -->
  <div id="admin">
    <input type="file"
           ref="file">
    <div v-html="md"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      md: "",
    };
  },
  mounted() {
    let _ = this;
    this.$refs.file.addEventListener("change", async function () {
      _.md = await require(`C:/Users/renhaohao/OneDrive/桌面/${this.value.slice(
        12
      )}`);
      _.$axios
        .post("http://localhost:3000/article/v1/add", { myfile: _.md })
        .then((res) => {
          if (res.data == 1) {
            console.log("添加成功");
          } else {
            console.log("添加失败");
          }
        });
    });
  },
};
</script>

<style lang="less" scoped></style>
